﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WikiTrailCreator.TrailImages
{
    public partial class FormGalleryCreator : Form
    {
        public FormGalleryCreator()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        public ImageGallery ImagesInGallery
        {
            get
            {
                return ucPhotoGalleryGroup1.ImagesInGallery;
            }
        }

        /// <summary>
        /// Builds the wiki code for this gallery.
        /// </summary>
        /// <returns>Wiki code for this gallery.</returns>
        public string GetInternalGalleryCode()
        {
            string wikiCode = "<imagegallery>" + Environment.NewLine;
            wikiCode += "<images>" + Environment.NewLine;

            ImageGallery imageGallery = this.ImagesInGallery;
            TrailImage[] imagesInGallery = imageGallery.Images;

            foreach (TrailImage trailImage in imagesInGallery)
            {
                wikiCode += "<image>" + trailImage.Id + "</image>" + Environment.NewLine;
            }

            wikiCode += "</images>" + Environment.NewLine;
            wikiCode += "</imagegallery>";

            return wikiCode;
        }
    }
}
